import { NDataTable, dataTableProps } from 'naive-ui'
import Toolbar from './components/toolbar'
import { useProTableState } from '@/components/pro-table/context.ts'

/**
 * @ClassName: index
 * @Description: // 入口文件
 * @Author: Ellwood
 * @CreateDate: 2024/2/23 - 7:46
 * @Version: V1.0.0
 */
const basicTable = defineComponent({
  name: 'BasicTable',
  props: { ...dataTableProps },
  setup(props, { slots }) {
    const prefixCls = 'pro-table-basic-table'

    const state = useProTableState()

    return () => {
      const tableSlots = {
        empty: slots.empty,
        loading: slots.loading,
      }

      return (
        <div class={prefixCls}>
          <Toolbar />
          <NDataTable
            {...props}
            columns={state.settingColumns?.cols.value}
            v-slots={tableSlots}
          >
          </NDataTable>
        </div>
      )
    }
  },
})

export default basicTable
